import { RemoveReadonly } from "@/utils/types";
import {
  DataTableProps,
  DataTableBaseColumn,
  PaginationSizeOption,
  PaginationProps,
} from "naive-ui";
import { VNodeChild } from "vue";

export type WritableDataTableProps = RemoveReadonly<DataTableProps>;
export type WritablePaginationProps = RemoveReadonly<PaginationProps>;

export interface ExtendedDataTableProps
  extends Omit<WritableDataTableProps, "pagination"> {
  pagination?: ZPaginationOptions;
  columns: ZTableColumn[];
}

export interface ZPaginationOptions {
  showTotal?: boolean;
  defaultPage?: number;
  defaultPageSize?: number;
  pageSizes?: Array<number | PaginationSizeOption>;
  showQuickJumper?: boolean;
  showSizePicker?: boolean;
  size?: "small" | "medium" | "large";
  disabled?: boolean;
}

export interface ZTableMethods {
  fetchDataSource: () => void;
  reload: () => void;
}

export type ZTableColumn = Omit<DataTableBaseColumn, "render"> & {
  render?: (
    meta: {
      rowData: any;
      rowIndex: number;
      methods: ZTableMethods;
    } & Omit<DataTableBaseColumn, "render">
  ) => VNodeChild;
};
